
<?php
if ($type_form == 'post') {

    echo form_open('admin/tbl_coupon/add');
} else {

    echo form_open('admin/tbl_coupon/update');
}
?>


<?php echo form_error('coupon_code'); ?>

<?php echo form_error('start_date'); ?>

<?php echo form_error('expired_date'); ?>

<?php echo form_error('jenis_coupon'); ?>

<?php echo form_error('nilai_coupon'); ?>

<?php echo form_error('limit_coupon_used'); ?>

<?php echo form_error('minimum_price'); ?>

<?php echo form_error('cat_product'); ?>

<table class="standard-table">
    
    <tr>
        <td>Code Coupon</td>
        <td><input type="text" name="coupon_code" value="<?php if(isset ($isi['coupon_code'])){echo $isi['coupon_code'];}?>" /></td>
    </tr>
    
    <tr>
        <td>Start Date</td>
        <td><input type="text" name="start_date" id="from" value="<?php if(isset ($isi['start_date'])){echo $isi['start_date'];}?>" /></td>
    </tr>
    
    <tr>
        <td>Expired Date</td>
        <td><input type="text" name="expired_date" id="to" value="<?php if(isset ($isi['expired_date'])){echo $isi['expired_date'];}?>" /></td>
    </tr>
    
    <tr>
        <td>Coupon Type</td>
        <td><select name="jenis_coupon">
                <option value="percent" <?php echo set_value('jenis_coupon')=='percent' ? "selected='selected'" : "";?> >Percentage Discount</option>
                <option value="nilai" <?php echo set_value('jenis_coupon')=='nilai' ? "selected='selected'" : "";?>>Value Discount</option>
            </select>
            
            <?php /*?><input type="text" name="jenis_coupon" value="<?php if(isset ($isi['jenis_coupon'])){echo $isi['jenis_coupon'];}?>" /><?php */?></td>
    </tr>
    
    <tr>
        <td>Coupon Value</td>
        <td><input type="text" name="nilai_coupon" value="<?php if(isset ($isi['nilai_coupon'])){echo $isi['nilai_coupon'];}?>" /></td>
    </tr>
    
    <tr>
        <td>Limit Coupon Used</td>
        <td><input type="text" name="limit_coupon_used" value="<?php if(isset ($isi['limit_coupon_used'])){echo $isi['limit_coupon_used'];}?>" /></td>
    </tr>
    
    <tr>
        <td>Minimum Price For Coupon</td>
        <td><input type="text" name="minimum_price" value="<?php if(isset ($isi['minimum_price'])){echo $isi['minimum_price'];}?>" /></td>
    </tr>
    
    <tr>
        <td>Product Categories</td>
        <td><input type="text" name="cat_product" value="<?php if(isset ($isi['cat_product'])){echo $isi['cat_product'];}?>" /></td>
    </tr>
    
   
    <tr>
        <td></td>
        <td>
               <?php if ($type_form == 'post') { ?>
            <input type="submit" name="post" value="Submit" />
               <?php } else { ?>

             <?php if(isset ($isi['id'])){ echo form_hidden('id',$isi['id']);}?>

            <input type="submit" name="update" value="update" />       
            
                <?php } ?>

        </td>
    </tr>
</table>




</form>
<script>
	$(function() {
	$( "#from" ).datepicker({
		defaultDate: "+1w",
		changeMonth: true,
		numberOfMonths: 3,
		onClose: function( selectedDate ) {
			$( "#to" ).datepicker( "option", "minDate", selectedDate );
		}
	});
	$( "#to" ).datepicker({
		defaultDate: "+1w",
		changeMonth: true,
		numberOfMonths: 3,
		onClose: function( selectedDate ) {
			$( "#from" ).datepicker( "option", "maxDate", selectedDate );
		}
		});
	});
</script>